<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:pou="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>Log Reports</title>        
    </h:head>
    <h:body>
        <pou:dialog closable="false" modal="true" header="Cargando" widgetVar="dlgwait">
            Espere un momento...<br />
            <h:graphicImage library="images" name="ajaxloader.gif" />
        </pou:dialog>        
        <h:form id="reportform">
            <ui:include src="header.xhtml" />
            <h:panelGroup rendered="#{usuario.loged}">
                <h:panelGrid id="datosreporte" width="800px" columns="2">
                    <pou:panel header="Actividad y Reportes">
                        <h:panelGrid>
                            <pou:dataTable rows="10"  rowKey="#{rep.nombre}"
                                           selectionMode="single" selection="#{mbReportes.selectedReport}"
                                           value="#{mbReportes.reportes}" var="rep">
                                <pou:ajax onstart="dlgwait.show()" event="rowSelect" listener="#{mbReportes.onSelectRow}"   
                                          update="@form"  onsuccess="dlgwait.hide()" />  
                                <pou:ajax onstart="dlgwait.show()" event="rowSelect" listener="#{mbReportes.unSelectRow}"   
                                          update="@form"  onsuccess="dlgwait.hide()" /> 
                                <pou:column>
                                    <f:facet name="header">
                                        <h:outputText value="Nombre Reporte" />
                                    </f:facet>
                                    <h:outputText value="#{rep.nombre}" />
                                </pou:column>
                            </pou:dataTable>
                            <h:panelGroup layout="block" style="width:500px;" >                                      
                                <pou:dataTable  id="dataparams" rowKey="#{pr.id}"
                                                value="#{mbReportes.currListParametros}" var="pr" >
                                    <pou:column style="width:30%">
                                        <f:facet name="header">
                                            <h:outputText value="Nombre Parametro" />
                                        </f:facet>
                                        <h:outputText value="#{pr.etiqueta}" />
                                    </pou:column>
                                    <pou:column style="width:70%" >
                                        <f:facet name="header">
                                            <h:outputText value="Valor Parametro" />
                                        </f:facet>
                                        <pou:cellEditor >                                        
                                            <f:facet name="output">
                                                <h:outputText value="#{pr.valor}" rendered="#{pr.singleEntry}"  />
                                                <h:outputText value="#{pr.selectedValue}" rendered="#{ pr.multiEntre}"  />
                                                <h:outputText value="#{pr.dateValue}" rendered="#{pr.calendar}"  />
                                            </f:facet>
                                            <f:facet name="input">
                                                <pou:inputText value="#{pr.valor}" rendered="#{pr.singleEntry}" />
                                                <pou:selectOneMenu rendered="#{pr.multiEntre}" value="#{pr.selectedValue}" >
                                                    <f:selectItems value="#{pr.listaValores}" var="it" itemLabel="#{it.descripcion}" itemValue="#{it.codigo}" />
                                                    <pou:ajax event="itemSelected" update="messages" />
                                                </pou:selectOneMenu>
                                                <pou:calendar pattern="dd/MM/yyyy HH:mm" value="#{pr.dateValue}" rendered="#{pr.calendar}"  ></pou:calendar>
                                                <pou:messages id="messages" />
                                            </f:facet>
                                        </pou:cellEditor>
                                    </pou:column> 
                                    <pou:column>
                                        <pou:rowEditor />
                                    </pou:column>
                                </pou:dataTable>
                            </h:panelGroup>
                            <h:panelGrid columns="3">
                                <h:commandLink style="padding-top: 5px; width: 36px; height: 31px;"  class="ui-button ui-widget ui-state-default ui-corner-all "   target="report" actionListener="#{mbReportes.generarReporte}">
                                    <h:graphicImage name="search.png" library="images" title="Visualizar" />
                                    <f:param name="tipo" value="prev" />
                                </h:commandLink>
                                <h:commandLink style="width: 36px; height: 36px;"  class="ui-button ui-widget ui-state-default ui-corner-all " rendered="#{usuario.permisoTodo}"   target="report" actionListener="#{mbReportes.generarReporte}">
                                    <h:graphicImage name="pdf.png" library="images" title="Enviar a PDF" />
                                    <f:param name="tipo" value="pdf" />
                                </h:commandLink>
                                <h:commandLink style="width: 36px; height: 36px;" class="ui-button ui-widget ui-state-default ui-corner-all " rendered="#{usuario.permisoTodo}" actionListener="#{mbReportes.generarReporte}">
                                    <h:graphicImage name="excel.png" library="images" title="Enviar a Excel" />
                                    <f:param name="tipo" value="xls" />
                                </h:commandLink>
                            </h:panelGrid>
                        </h:panelGrid>
                    </pou:panel>
                </h:panelGrid>
                <pou:panel visible="true" widgetVar="dlgreport" id="reportarea" header="Salida Reporte">
                    <f:facet name="title">Reporte</f:facet>
                    <iframe frameborder="no" style="width:100%; height: 1000px; " src="#" id="report" name="report" />
                    <script type="text/javascript">
                        $('#report',$(document)).load(function(){
                            dlgwait.hide();
                        });

                    </script>
                </pou:panel>
            </h:panelGroup>
            <h:panelGroup rendered="#{!usuario.loged}">
                <ui:include src="login.xhtml"></ui:include>
            </h:panelGroup>
        </h:form>

    </h:body>
</html>

